package com.xcjh.exception;

import com.xcjh.base.dto.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


//@ControllerAdvice  此注解的类会在controler类执行之前或者执行之后，处理一些逻辑
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(GlobalException.class)
    public Result globalException(GlobalException e){
        return Result.error(e.getMessage());
    }


    @ExceptionHandler(Exception.class)
    public Result globalException(Exception e){
        e.printStackTrace();
        return Result.error(e.getMessage());
    }
}